deploy: Ensure that all directories we create are fsync()d
authorColin Walters <walters@verbum.org>
Tue, 8 Apr 2014 21:24:07 +0000 (17:24 -0400)
committerColin Walters <walters@verbum.org>
Fri, 11 Apr 2014 22:43:13 +0000 (18:43 -0400)
There's two halves to this; first, when we create an hierarchy, we
need to call fsync().  Second, we need to fsync again anytime after
we've modified a directory.

src/libostree/ostree-sysroot-deploy.c

index 5f99fec50abf4e282d936a5a57b6610212994e18..8af5f2c2942ea963389759d2dd95c3198853177b 100644 (file)
@@ -220,7 +220,7 @@ checkout_deployment_tree (OstreeSysroot     *sysroot,
   deploy_target_path = g_file_get_child (osdeploy_path, checkout_target_name);
 
   deploy_parent = g_file_get_parent (deploy_target_path);
-  if (!gs_file_ensure_directory (deploy_parent, TRUE, cancellable, error))
+  if (!ot_util_ensure_directory_and_fsync (deploy_parent, cancellable, error))
     goto out;
   
   g_print ("ostadmin: Creating deployment %s\n",
@@ -732,7 +732,7 @@ swap_bootlinks (OstreeSysroot *self,
   ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion);
   ostree_subbootdir = g_file_resolve_relative_path (ostree_dir, ostree_subbootdir_name);
 
-  if (!gs_file_ensure_directory (ostree_subbootdir, TRUE, cancellable, error))
+  if (!ot_util_ensure_directory_and_fsync (ostree_subbootdir, cancellable, error))
     goto out;
 
   for (i = 0; i < new_deployments->len; i++)
@@ -749,9 +749,9 @@ swap_bootlinks (OstreeSysroot *self,
       gs_unref_object GFile *linkname = g_file_get_child (ostree_subbootdir, bootlink_pathname);
       gs_unref_object GFile *linkname_parent = g_file_get_parent (linkname);
 
-      if (!gs_file_ensure_directory (linkname_parent, TRUE, cancellable, error))
+      if (!ot_util_ensure_directory_and_fsync (linkname_parent, cancellable, error))
         goto out;
-
+      
       if (!g_file_make_symbolic_link (linkname, bootlink_target, cancellable, error))
         goto out;
     }
@@ -866,10 +866,10 @@ install_deployment_kernel (OstreeSysroot   *sysroot,
                                                new_bootversion, osname, 
                                                ostree_deployment_get_index (deployment));
 
-  if (!gs_file_ensure_directory (bootcsumdir, TRUE, cancellable, error))
+  if (!ot_util_ensure_directory_and_fsync (bootcsumdir, cancellable, error))
     goto out;
   bootconfpath_parent = g_file_get_parent (bootconfpath);
-  if (!gs_file_ensure_directory (bootconfpath_parent, TRUE, cancellable, error))
+  if (!ot_util_ensure_directory_and_fsync (bootconfpath_parent, cancellable, error))
     goto out;
 
   dest_kernel_name = remove_checksum_from_kernel_name (gs_file_get_basename_cached (tree_kernel_path),
@@ -1180,7 +1180,7 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
 
       new_loader_entries_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d/entries",
                                                              new_bootversion);
-      if (!gs_file_ensure_directory (new_loader_entries_dir, TRUE, cancellable, error))
+      if (!ot_util_ensure_directory_and_fsync (new_loader_entries_dir, cancellable, error))
         goto out;
       
       for (i = 0; i < new_deployments->len; i++)